<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">

	<ui:define name="content">
		<f:event type="preRenderView" listener="#{ojtController.beforeSearch}" />

		<div class="title ui-widget-header ui-corner-all">
			<h:panelGrid style="margin:auto;">
		BUSCAR OJT's
		</h:panelGrid>

		</div>

		<h:form id="formSearch">
			<h:panelGrid style="margin:auto;">
				<h:panelGrid style="margin:auto;text-align:center;">
					<p:messages id="messages"></p:messages>
				</h:panelGrid>
				
				<h:panelGrid columns="6">

					
						<p:outputLabel value="N° de documento"></p:outputLabel>
						<p:inputText style="width: 180px;"
							value="#{ojtController.candidateDocumentNumberSearch}"></p:inputText>
						<p:outputLabel value="Nombres"></p:outputLabel>
						<p:inputText style="width: 180px;"
							value="#{ojtController.candidateFirstnameSearch}"></p:inputText>
						<p:outputLabel value="Apellidos"></p:outputLabel>
						<p:inputText style="width: 180px;"
							value="#{ojtController.candidateLastnameSearch}"></p:inputText>
							
							<p:outputLabel value="Area"></p:outputLabel>
					<p:selectOneMenu id="areas"
						value="#{ojtController.areaSelected}">
						<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
						<f:selectItems value="#{ojtController.areas}"></f:selectItems>
						<p:ajax listener="#{ojtController.searchSubAreas}"
							update=":formSearch:subAreas :formSearch:messages"></p:ajax>
					</p:selectOneMenu>
					<p:outputLabel value="Subarea"></p:outputLabel>
					<p:selectOneMenu id="subAreas"
						value="#{ojtController.subAreaSelected}">
						<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
						<f:selectItems value="#{ojtController.subAreas}"></f:selectItems>
					</p:selectOneMenu>
					
					<p:outputLabel value="Reclutador"></p:outputLabel>
					<p:selectOneMenu id="recruitments"
						value="#{ojtController.recruiterSelected}">
						<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
						<f:selectItems value="#{ojtController.recruiters}"></f:selectItems>
					</p:selectOneMenu>
					

						<p:outputLabel value="Fecha de OJT"></p:outputLabel>
						<p:calendar value="#{ojtController.ojtAtSearch}"></p:calendar>


						<p:outputLabel value="Estado"></p:outputLabel>
						<p:selectOneMenu id="states"
							value="#{ojtController.stateSelected}">
							<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
							<f:selectItems value="#{ojtController.states}"></f:selectItems>
						</p:selectOneMenu>
					
				</h:panelGrid>
				<h:panelGrid style="margin:auto;text-align:center;">
					<p:commandButton icon="ui-icon-search"
						actionListener="#{ojtController.search}" value="Buscar"
						process="@form"
						update=":formSearch:searchTable :formSearch:messages">
					</p:commandButton>
				</h:panelGrid>
			</h:panelGrid>
			<h:panelGrid columns="2">
				

				<p:commandButton id="editButtom" action="edit_ojt.xhtml"
					icon="ui-icon-pencil" value="Editar"
					disabled="#{ojtController.ojtSelected==null}">
					<f:param name="ojtId" value="#{ojtController.ojtSelected.id}"></f:param>
				</p:commandButton>
				<p:outputLabel id="ojtId"
					value="Ojt seleccionada: #{ojtController.ojtSelected!=null?ojtController.ojtSelected.id:''}">
				</p:outputLabel>
			</h:panelGrid>

			<p:dataTable value="#{ojtController.ojts}" var="o" rowKey="#{o.id}"
				paginator="true" rows="10" id="searchTable" selectionMode="single"
				selection="#{ojtController.ojtSelected}">
				<p:ajax event="rowSelect"
					update=":formSearch:ojtId :formSearch:editButtom" />
				<p:ajax event="rowUnselect"
					update=":formSearch:ojtId :formSearch:editButtom" />

				<p:column headerText="ID" sortBy="#{o.id}">
					<h:outputText value="#{o.id}"></h:outputText>
				</p:column>

				<p:column headerText="DNI"
					sortBy="#{o.training.interview.candidate.documentNumber}">
					<h:outputText
						value="#{o.training.interview.candidate.documentNumber}"></h:outputText>
				</p:column>

				<p:column headerText="Nombres"
					sortBy="#{o.training.interview.candidate.firstname}">
					<h:outputText value="#{o.training.interview.candidate.firstname}"></h:outputText>
				</p:column>

				<p:column headerText="Apellidos"
					sortBy="#{o.training.interview.candidate.lastname}">
					<h:outputText value="#{o.training.interview.candidate.lastname}"></h:outputText>
				</p:column>
				
				<p:column headerText="Area"
					sortBy="#{o.training.interview.candidate.area.area.name}">
					<h:outputText value="#{o.training.interview.candidate.area.area.name}"></h:outputText>
				</p:column>

				<p:column headerText="Subarea"
					sortBy="#{o.training.interview.candidate.area.name}">
					<h:outputText value="#{o.training.interview.candidate.area.name}"></h:outputText>
				</p:column>
				
				<p:column headerText="Estado" sortBy="#{o.ojtState.name}">
					<h:outputText value="#{o.ojtState.name}"></h:outputText>
				</p:column>
				
				<p:column headerText="Fecha de OJT" sortBy="#{o.ojtAt}">
					<h:outputText value="#{o.ojtAt}">
						<f:convertDateTime pattern="dd-MM-yyyy hh:mm:ss a" />
					</h:outputText>
				</p:column>
				
				<p:column headerText="Reclutador"
					sortBy="#{o.recruiter.firstname} #{o.recruiter.lastname}">
					<h:outputText
						value="#{o.recruiter.firstname} #{o.recruiter.lastname}"></h:outputText>
				</p:column>

				<p:column headerText="Fecha de creación" sortBy="#{o.createdAt}">
					<h:outputText value="#{o.createdAt}">
						<f:convertDateTime pattern="dd-MM-yyyy hh:mm:ss a" />
					</h:outputText>
				</p:column>

				<p:column headerText="Comentarios" sortBy="#{o.comment}">
					<h:outputText value="#{o.comment}"></h:outputText>
				</p:column>



			</p:dataTable>


		</h:form>
	</ui:define>

</ui:composition>
</html>
